<?php

// 获取我的信息
// GET member.uinfo

namespace app\api\resource\member;
use think\Db;
use think\facade\Config;
use think\facade\Session;

class Uinfo
{
    // 方法
    public $_method = ['GET'];
    // 前置
    public $_pre    = ['member'];
    // 描述
    public $_description = '获取我的信息';
    // 参数
    public $_param  = [];

    public function run(&$request)
    {
        $member = Session::get('member');
        $member = Db::name('member')->where('id',$member['id'])->field('password',true)->find();
		
		$member['reffer']     = rtrim( base64_encode($member['id']),'==' );
        $member['nickname']   = empty($member['nickname'])   ? Config::get('sg.default_nickname')   : $member['nickname'];
        $member['headimgurl'] = empty($member['headimgurl']) ? Config::get('sg.default_headimgurl') : $member['headimgurl'];

        unset($member['id'],
              $member['pid'],
              $member['status'],
              $member['delete_time']);

        $member['cert'] = $member['expire'] > time();

        return [200,$member];
    }
}
